//
// Copyright (C) 2011 - 2013  Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.2 with QuantLib 1.2.1
//#include "stdafx.h"
#include "ZeroCouponInflationSwap.h"
using namespace Cephei::QL::Instruments;
#include <gen/QL/Times/DayCounter.h>
#include <gen/QL/CashFlow.h>
#include <gen/QL/Indexes/ZeroInflationIndex.h>
#include <gen/QL/Times/Period.h>
#include <gen/QL/Times/Calendar.h>
#include <gen/QL/PricingEngine.h>
#include <gen/QL/Instruments/Swap.h>
using namespace Cephei::QL::Times;
using namespace Cephei::QL;
using namespace Cephei::QL::Indexes;
#define HANDLE
#undef ABSTRACT
#undef STRUCT
Cephei::QL::Instruments::CZeroCouponInflationSwap::CZeroCouponInflationSwap (QL::Instruments::ZeroCouponInflationSwap::TypeEnum type, Double nominal, DateTime startDate, DateTime maturity, Cephei::QL::Times::ICalendar^ fixCalendar, QL::Times::BusinessDayConventionEnum fixConvention, Cephei::QL::Times::IDayCounter^ dayCounter, Double fixedRate, Cephei::QL::Indexes::IZeroInflationIndex^ infIndex, Cephei::QL::Times::IPeriod^ observationLag, Microsoft::FSharp::Core::FSharpOption<Boolean>^ adjustInfObsDates, Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::ICalendar^>^ infCalendar, Microsoft::FSharp::Core::FSharpOption<QL::Times::BusinessDayConventionEnum>^ infConvention, Cephei::QL::IPricingEngine^ QL_Pricer) : CSwap(CZeroCouponInflationSwap::typeid)
{
    CCalendar^ _CfixCalendar;
    CDayCounter^ _CdayCounter;
    CZeroInflationIndex^ _CinfIndex;
    CPeriod^ _CobservationLag;
    CCalendar^ _CinfCalendar;
    try
    {
#ifdef HANDLE
        _phZeroCouponInflationSwap = NULL;
#endif
        QuantLib::ZeroCouponInflationSwap::Type _type = (QuantLib::ZeroCouponInflationSwap::Type)type ;
        QuantLib::Real _nominal = (QuantLib::Real)ValueHelper::Convert (nominal); //d
        QuantLib::Date _startDate = (QuantLib::Date)ValueHelper::Convert (startDate); //d
        QuantLib::Date _maturity = (QuantLib::Date)ValueHelper::Convert (maturity); //d
        _CfixCalendar = safe_cast<CCalendar^> (fixCalendar);
        _CfixCalendar->Lock();
        QuantLib::Calendar& _fixCalendar = static_cast<QuantLib::Calendar&> (_CfixCalendar->GetReference ()); 
        QuantLib::BusinessDayConvention _fixConvention = (QuantLib::BusinessDayConvention)fixConvention ;
        _CdayCounter = safe_cast<CDayCounter^> (dayCounter);
        _CdayCounter->Lock();
        QuantLib::DayCounter& _dayCounter = static_cast<QuantLib::DayCounter&> (_CdayCounter->GetReference ()); 
        QuantLib::Rate _fixedRate = (QuantLib::Rate)ValueHelper::Convert (fixedRate); //d
        _CinfIndex = safe_cast<CZeroInflationIndex^> (infIndex);
        _CinfIndex->Lock();
        boost::shared_ptr<QuantLib::ZeroInflationIndex>& _infIndex = static_cast<boost::shared_ptr<QuantLib::ZeroInflationIndex>&> (_CinfIndex->GetShared ()); 
        _CobservationLag = safe_cast<CPeriod^> (observationLag);
        _CobservationLag->Lock();
        QuantLib::Period& _observationLag = static_cast<QuantLib::Period&> (_CobservationLag->GetReference ()); 
        bool _adjustInfObsDates = 
            (Microsoft::FSharp::Core::FSharpOption<Boolean>::IsSome::get (adjustInfObsDates) ? (bool)ValueHelper::Convert (adjustInfObsDates->Value) : false); //4
        if (Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::ICalendar^>::IsSome::get (infCalendar))
        {
            _CinfCalendar = safe_cast<CCalendar^> (infCalendar->Value);
            _CinfCalendar->Lock();
        }
        QuantLib::Calendar _infCalendar = 
            (Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::ICalendar^>::IsSome::get (infCalendar) ? static_cast<QuantLib::Calendar> (_CinfCalendar->GetReference ()) : QuantLib::Calendar()); //1
        QuantLib::BusinessDayConvention _infConvention = 
            (Microsoft::FSharp::Core::FSharpOption<QL::Times::BusinessDayConventionEnum>::IsSome::get (infConvention) ? (QuantLib::BusinessDayConvention)infConvention->Value : QuantLib::BusinessDayConvention::Following); //10
        _ppZeroCouponInflationSwap = new boost::shared_ptr<QuantLib::ZeroCouponInflationSwap> (new QuantLib::ZeroCouponInflationSwap ( _type,  _nominal,  _startDate,  _maturity,  _fixCalendar,  _fixConvention,  _dayCounter,  _fixedRate,  _infIndex,  _observationLag,  _adjustInfObsDates,  _infCalendar,  _infConvention ));
        CPricingEngine^ _CQL_Pricer = safe_cast<CPricingEngine^> (QL_Pricer);
        boost::shared_ptr<QuantLib::PricingEngine>& _QL_Pricer = static_cast<boost::shared_ptr<QuantLib::PricingEngine>&> (_CQL_Pricer->GetShared ());
        (*_ppZeroCouponInflationSwap)->setPricingEngine (_QL_Pricer);
        SetSwap (boost::dynamic_pointer_cast<QuantLib::Swap> (*_ppZeroCouponInflationSwap));
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
        if (_CfixCalendar != nullptr) _CfixCalendar->Unlock();
        if (_CdayCounter != nullptr) _CdayCounter->Unlock();
        if (_CinfIndex != nullptr) _CinfIndex->Unlock();
        if (_CobservationLag != nullptr) _CobservationLag->Unlock();
        if (_CinfCalendar != nullptr) _CinfCalendar->Unlock();
    }
}
Cephei::QL::Instruments::CZeroCouponInflationSwap::CZeroCouponInflationSwap (boost::shared_ptr<QuantLib::ZeroCouponInflationSwap>& childNative, Object^ owner) : CSwap(CZeroCouponInflationSwap::typeid)
{
#ifdef HANDLE
	_phZeroCouponInflationSwap = NULL;
#endif
	_ppZeroCouponInflationSwap = &childNative;
    _ppSwap = new boost::shared_ptr<QuantLib::Swap> (boost::dynamic_pointer_cast<QuantLib::Swap> (*_ppZeroCouponInflationSwap));
}
Cephei::QL::Instruments::CZeroCouponInflationSwap::CZeroCouponInflationSwap (QuantLib::ZeroCouponInflationSwap& childNative, Object^ owner) : CSwap(CZeroCouponInflationSwap::typeid)
{
#ifdef HANDLE
	_phZeroCouponInflationSwap = NULL;
#endif
	_ppZeroCouponInflationSwap = new boost::shared_ptr<QuantLib::ZeroCouponInflationSwap> (&childNative);
    _ppSwap = new boost::shared_ptr<QuantLib::Swap> (boost::dynamic_pointer_cast<QuantLib::Swap> (*_ppZeroCouponInflationSwap));
    _ZeroCouponInflationSwapOwner = owner;
    _SwapOwner = owner;
}

Cephei::QL::Instruments::CZeroCouponInflationSwap::CZeroCouponInflationSwap (CZeroCouponInflationSwap^ copy) : CSwap(CZeroCouponInflationSwap::typeid)
{
#ifdef HANDLE
	_phZeroCouponInflationSwap = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppZeroCouponInflationSwap = new boost::shared_ptr<QuantLib::ZeroCouponInflationSwap> (copy->GetShared());
        _ppSwap = new boost::shared_ptr<QuantLib::Swap> (boost::dynamic_pointer_cast<QuantLib::Swap> (*_ppZeroCouponInflationSwap));
    }
}
Cephei::QL::Instruments::CZeroCouponInflationSwap::CZeroCouponInflationSwap (PLATFORM::Type^ t) : CSwap(CZeroCouponInflationSwap::typeid)
{
#ifdef HANDLE
	_phZeroCouponInflationSwap = NULL;
#endif
	if (!t->IsSubclassOf(CZeroCouponInflationSwap::typeid))
		throw REFNEW Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Instruments::CZeroCouponInflationSwap::CZeroCouponInflationSwap (QuantLib::Handle<QuantLib::ZeroCouponInflationSwap>& childNative, Object^ owner)  : CSwap(CZeroCouponInflationSwap::typeid)
{
	_phZeroCouponInflationSwap = &childNative;
	_ppZeroCouponInflationSwap = &static_cast<boost::shared_ptr<QuantLib::ZeroCouponInflationSwap>>(childNative.currentLink());
    _ppSwap = new boost::shared_ptr<QuantLib::Swap> (boost::dynamic_pointer_cast<QuantLib::Swap> (*_ppZeroCouponInflationSwap));
    _ZeroCouponInflationSwapOwner = owner;
}
Cephei::QL::Instruments::CZeroCouponInflationSwap::CZeroCouponInflationSwap (QuantLib::Handle<QuantLib::ZeroCouponInflationSwap> childNative)  : CSwap(CZeroCouponInflationSwap::typeid)
{
	_phZeroCouponInflationSwap = &childNative;
	_ppZeroCouponInflationSwap = &static_cast<boost::shared_ptr<QuantLib::ZeroCouponInflationSwap>>(childNative.currentLink());
    _ppSwap = new boost::shared_ptr<QuantLib::Swap> (boost::dynamic_pointer_cast<QuantLib::Swap> (*_ppZeroCouponInflationSwap));
}
#endif
#ifdef STRUCT
Cephei::QL::Instruments::CZeroCouponInflationSwap::CZeroCouponInflationSwap (QuantLib::ZeroCouponInflationSwap childNative)  : CSwap(CZeroCouponInflationSwap::typeid)
{
#ifdef HANDLE
	_phZeroCouponInflationSwap = NULL;
#endif
	_ppZeroCouponInflationSwap = new boost::shared_ptr<QuantLib::ZeroCouponInflationSwap> (new QuantLib::ZeroCouponInflationSwap (childNative));
    _ppSwap = new boost::shared_ptr<QuantLib::Swap> (boost::dynamic_pointer_cast<QuantLib::Swap> (*_ppZeroCouponInflationSwap));
}
#endif

Cephei::QL::Instruments::CZeroCouponInflationSwap::~CZeroCouponInflationSwap ()
{
    if (_ppZeroCouponInflationSwap != NULL)
    {
	    delete _ppZeroCouponInflationSwap;
        _ppZeroCouponInflationSwap = NULL;
    }
}
Cephei::QL::Instruments::CZeroCouponInflationSwap::!CZeroCouponInflationSwap ()
{
    if (_ppZeroCouponInflationSwap != NULL)
    {
	    delete _ppZeroCouponInflationSwap;
    }
}
QuantLib::ZeroCouponInflationSwap& Cephei::QL::Instruments::CZeroCouponInflationSwap::GetReference ()
{
    if (_ppZeroCouponInflationSwap == NULL) throw REFNEW NativeNullException ();
	return **_ppZeroCouponInflationSwap;
}
boost::shared_ptr<QuantLib::ZeroCouponInflationSwap>& Cephei::QL::Instruments::CZeroCouponInflationSwap::GetShared ()
{
    if (_ppZeroCouponInflationSwap == NULL) throw REFNEW NativeNullException ();
	return *_ppZeroCouponInflationSwap;
}
QuantLib::ZeroCouponInflationSwap* Cephei::QL::Instruments::CZeroCouponInflationSwap::GetPointer ()
{
    if (_ppZeroCouponInflationSwap == NULL) throw REFNEW NativeNullException ();
	return &**_ppZeroCouponInflationSwap;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::ZeroCouponInflationSwap>& Cephei::QL::Instruments::CZeroCouponInflationSwap::GetHandle ()
{
	if (_phZeroCouponInflationSwap == NULL)
	{
		_phZeroCouponInflationSwap = new Handle<QuantLib::ZeroCouponInflationSwap> (*_ppZeroCouponInflationSwap);
	}
	return *_phZeroCouponInflationSwap;
}
#endif
bool Cephei::QL::Instruments::CZeroCouponInflationSwap::HasNative () 
{
	return (_ppZeroCouponInflationSwap != NULL);
}

Double Cephei::QL::Instruments::CZeroCouponInflationSwap::FairRate::get ()
{
    try
    {
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppZeroCouponInflationSwap)->fairRate ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Instruments::CZeroCouponInflationSwap::FixedRate::get ()
{
    try
    {
    	QuantLib::Rate _rv = (QuantLib::Rate)(*_ppZeroCouponInflationSwap)->fixedRate ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Times::IDayCounter^ Cephei::QL::Instruments::CZeroCouponInflationSwap::DayCounter::get ()
{
    try
    {
    	QuantLib::DayCounter _rv = (QuantLib::DayCounter)(*_ppZeroCouponInflationSwap)->dayCounter ( );   
        Cephei::QL::Times::CDayCounter^ _nrv = REFNEW Cephei::QL::Times::CDayCounter (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::Core::IVector<Cephei::QL::ICashFlow^>^ Cephei::QL::Instruments::CZeroCouponInflationSwap::FixedLeg::get ()
{
    try
    {
    	std::vector<boost::shared_ptr<QuantLib::CashFlow> >& _rv = (std::vector<boost::shared_ptr<QuantLib::CashFlow> >&)(*_ppZeroCouponInflationSwap)->fixedLeg ( );   
        CoVector<Cephei::QL::ICashFlow^>^ _nrv = REFNEW CoVector<Cephei::QL::ICashFlow^>(REFNEW CCashFlowVector (_rv, this));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Instruments::CZeroCouponInflationSwap::FixedLegNPV::get ()
{
    try
    {
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppZeroCouponInflationSwap)->fixedLegNPV ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Indexes::IZeroInflationIndex^ Cephei::QL::Instruments::CZeroCouponInflationSwap::InflationIndex::get ()
{
    try
    {
    	boost::shared_ptr<QuantLib::ZeroInflationIndex> _rv = (boost::shared_ptr<QuantLib::ZeroInflationIndex>)(*_ppZeroCouponInflationSwap)->inflationIndex ( );   
        Cephei::QL::Indexes::CZeroInflationIndex^ _nrv = REFNEW Cephei::QL::Indexes::CZeroInflationIndex (_rv, this);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::Core::IVector<Cephei::QL::ICashFlow^>^ Cephei::QL::Instruments::CZeroCouponInflationSwap::InflationLeg::get ()
{
    try
    {
    	std::vector<boost::shared_ptr<QuantLib::CashFlow> >& _rv = (std::vector<boost::shared_ptr<QuantLib::CashFlow> >&)(*_ppZeroCouponInflationSwap)->inflationLeg ( );   
        CoVector<Cephei::QL::ICashFlow^>^ _nrv = REFNEW CoVector<Cephei::QL::ICashFlow^>(REFNEW CCashFlowVector (_rv, this));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Instruments::CZeroCouponInflationSwap::InflationLegNPV::get ()
{
    try
    {
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppZeroCouponInflationSwap)->inflationLegNPV ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Instruments::CZeroCouponInflationSwap::Nominal::get ()
{
    try
    {
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppZeroCouponInflationSwap)->nominal ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Times::IPeriod^ Cephei::QL::Instruments::CZeroCouponInflationSwap::ObservationLag::get ()
{
    try
    {
    	QuantLib::Period _rv = (QuantLib::Period)(*_ppZeroCouponInflationSwap)->observationLag ( );   
        Cephei::QL::Times::CPeriod^ _nrv = REFNEW Cephei::QL::Times::CPeriod (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
QL::Instruments::ZeroCouponInflationSwap::TypeEnum Cephei::QL::Instruments::CZeroCouponInflationSwap::Type::get ()
{
    try
    {
    	QuantLib::ZeroCouponInflationSwap::Type _rv = (QuantLib::ZeroCouponInflationSwap::Type)(*_ppZeroCouponInflationSwap)->type ( );   
        QL::Instruments::ZeroCouponInflationSwap::TypeEnum _nrv = (QL::Instruments::ZeroCouponInflationSwap::TypeEnum)_rv;
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Boolean Cephei::QL::Instruments::CZeroCouponInflationSwap::AdjustObservationDates::get ()
{
    try
    {
    	bool _rv = (bool)(*_ppZeroCouponInflationSwap)->adjustObservationDates ( );   
        Boolean _nrv = (Boolean)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Times::ICalendar^ Cephei::QL::Instruments::CZeroCouponInflationSwap::FixedCalendar::get ()
{
    try
    {
    	QuantLib::Calendar _rv = (QuantLib::Calendar)(*_ppZeroCouponInflationSwap)->fixedCalendar ( );   
        Cephei::QL::Times::CCalendar^ _nrv = REFNEW Cephei::QL::Times::CCalendar (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
QL::Times::BusinessDayConventionEnum Cephei::QL::Instruments::CZeroCouponInflationSwap::FixedConvention::get ()
{
    try
    {
    	QuantLib::BusinessDayConvention _rv = (QuantLib::BusinessDayConvention)(*_ppZeroCouponInflationSwap)->fixedConvention ( );   
        QL::Times::BusinessDayConventionEnum _nrv = (QL::Times::BusinessDayConventionEnum)_rv;
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Times::ICalendar^ Cephei::QL::Instruments::CZeroCouponInflationSwap::InflationCalendar::get ()
{
    try
    {
    	QuantLib::Calendar _rv = (QuantLib::Calendar)(*_ppZeroCouponInflationSwap)->inflationCalendar ( );   
        Cephei::QL::Times::CCalendar^ _nrv = REFNEW Cephei::QL::Times::CCalendar (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
QL::Times::BusinessDayConventionEnum Cephei::QL::Instruments::CZeroCouponInflationSwap::InflationConvention::get ()
{
    try
    {
    	QuantLib::BusinessDayConvention _rv = (QuantLib::BusinessDayConvention)(*_ppZeroCouponInflationSwap)->inflationConvention ( );   
        QL::Times::BusinessDayConventionEnum _nrv = (QL::Times::BusinessDayConventionEnum)_rv;
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
DateTime Cephei::QL::Instruments::CZeroCouponInflationSwap::MaturityDate::get ()
{
    try
    {
    	QuantLib::Date _rv = (QuantLib::Date)(*_ppZeroCouponInflationSwap)->maturityDate ( );   
        DateTime _nrv = (DateTime)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
DateTime Cephei::QL::Instruments::CZeroCouponInflationSwap::StartDate::get ()
{
    try
    {
    	QuantLib::Date _rv = (QuantLib::Date)(*_ppZeroCouponInflationSwap)->startDate ( );   
        DateTime _nrv = (DateTime)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

Cephei::QL::Instruments::IZeroCouponInflationSwap^ Cephei::QL::Instruments::CZeroCouponInflationSwap_Factory::Create (QL::Instruments::ZeroCouponInflationSwap::TypeEnum type, Double nominal, DateTime startDate, DateTime maturity, Cephei::QL::Times::ICalendar^ fixCalendar, QL::Times::BusinessDayConventionEnum fixConvention, Cephei::QL::Times::IDayCounter^ dayCounter, Double fixedRate, Cephei::QL::Indexes::IZeroInflationIndex^ infIndex, Cephei::QL::Times::IPeriod^ observationLag, Microsoft::FSharp::Core::FSharpOption<Boolean>^ adjustInfObsDates, Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::ICalendar^>^ infCalendar, Microsoft::FSharp::Core::FSharpOption<QL::Times::BusinessDayConventionEnum>^ infConvention, Cephei::QL::IPricingEngine^ QL_Pricer)
{
    return REFNEW CZeroCouponInflationSwap ( type,  nominal,  startDate,  maturity,  fixCalendar,  fixConvention,  dayCounter,  fixedRate,  infIndex,  observationLag,  adjustInfObsDates,  infCalendar,  infConvention,  QL_Pricer);
}
